//
//  ViewController.m
//  iOSDemoProject
//
//  Created by fangshufeng on 2018/3/23.
//  Copyright © 2018年 fangshufeng. All rights reserved.
//

#import "ViewController.h"
#import "Demo0ViewController.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>


@property(nonatomic, strong) NSMutableArray *dataArray;

/***/
@property(nonatomic, strong) NSMutableArray *descrArray;
@end

@implementation ViewController

- (NSMutableArray *)dataArray {
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array ];
        for (int i = 0 ; i < 1; i++) {
            [_dataArray addObject:[NSString stringWithFormat:@"Demo%dViewController",i]];
        }
        
    }
    return _dataArray;
}

- (NSMutableArray *)descrArray {
    if (_descrArray == nil) {
        _descrArray = [NSMutableArray array ];
        [_descrArray addObject:@"exchange_Imp方法"];

    }
    return _descrArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UITableView *tab = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,Kmainwidth , Kmainheight - 64) style:UITableViewStylePlain];
    tab.delegate  =self;
    tab.dataSource = self;
    [self.view addSubview:tab];
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    NSString *desct = indexPath.row >=  self.descrArray.count ? self.dataArray[self.dataArray.count - 1 - indexPath.row] : self.descrArray[self.descrArray.count - 1-  indexPath.row];
    
    cell.textLabel.text = desct;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *vc = [[NSClassFromString(self.dataArray[self.dataArray.count - 1 - indexPath.row]) alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
